home *** CD-ROM | disk | FTP | other *** search
/ L' Effet Pommier 3 / L'Effet Pommier - Volume 03.iso / Programmation / Gooey1.3.1 / C Templates / mmModalDialog.c < prev    next >
Text File  |  1994-04-17  |  22KB  |  616 lines

  1. $$Loop ModalDialogs
  2. $$Message MM Modal Dialog, mm:mmD_$Worksheet.name$.c
  3.  
  4. $$File mm:mmD_$Worksheet.name$.c
  5. /*  mmD_$Worksheet.name$                                 Handle this dialog */
  6. /*  $CopyRight$ */
  7.  
  8. /*    File name:  mmD_$Worksheet.name$.c
  9.     Function:  Handle this modal dialog.
  10.  
  11.     This dialog is called when:
  12.  
  13.     History: $Date$ Original by $Author$
  14.  
  15. */
  16.  
  17. #include "mmCommon$Prototype.name$.h"    /* Common */
  18. #include "Common$Prototype.name$.h"        /* Common */
  19.  
  20. #include "$Worksheet.name$.h"            /* Users specific file */
  21.  
  22. /* ======================================================= */
  23. /* ======================================================= */
  24.  
  25. /* Prototypes */
  26.  
  27. /* Filter routine for modal dialog routine */
  28. static pascal Boolean MyFilter (DialogPtr theDialog ,EventRecord *theEvent,short *itemHit);
  29.  
  30. /* This is an update routine for non-controls in the dialog */
  31. /* This is executed after the dialog is uncovered by an alert */
  32. static void Refresh_Dialog(void);                    /* Refresh the dialogs non-controls */
  33.  
  34. /* ======================================================= */
  35.  
  36. /* Routine: InitD_$Worksheet.name$ */
  37. /* Purpose: Initialize the modal dialog, globals and call users routine */
  38.  
  39. void InitD_$Worksheet.name$(void)
  40. {
  41.  
  42.  
  43. Rec_$Worksheet.name$.theDialog = nil;
  44.  
  45. $$Loop Control.type = Button
  46. Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;        /* Button */
  47. $$EndLoop
  48. $$Loop Control.type = HotRect
  49. $$if Control.HotSpot
  50. Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;        /* HotSpot  */
  51. $$endif
  52. $$EndLoop
  53. $$Loop Control.type = Checkbox
  54. Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;        /* Checkbox  */
  55. $$if Control.Selected
  56. Rec_$Worksheet.name$.Value_$Control.name$ = 1;
  57. $$endif
  58. $$if Control.Unselected
  59. Rec_$Worksheet.name$.Value_$Control.name$ = 0;
  60. $$endif
  61. $$EndLoop
  62. $$Loop Control.type = Radio
  63. Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;        /* Radio */
  64. $$if Control.Selected
  65. Rec_$Worksheet.name$.Value_$Control.name$ = 1;
  66. $$endif
  67. $$if Control.Unselected
  68. Rec_$Worksheet.name$.Value_$Control.name$ = 0;
  69. $$endif
  70. $$EndLoop
  71. $$Loop Control.type = ScrollBar
  72. Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;        /* ScrollBar */
  73. Rec_$Worksheet.name$.Value_$Control.name$ = $Control.ValueScroll$;
  74. $$EndLoop
  75. $$Loop Control.type = Icon
  76. Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;        /* Icon button  */
  77. $$EndLoop
  78. $$Loop Control.type = Sicn
  79. Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;        /* Sicn button  */
  80. $$EndLoop
  81. $$Loop Control.type = Picture
  82. $$if Control.NonGraphic
  83. Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;        /* Picture button  */
  84. $$endif
  85. $$EndLoop
  86. $$Loop Control.type = UButton
  87. Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;        /* Plugin button */
  88. $$EndLoop
  89. $$Loop Control.type = UToggle
  90. Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;        /* Plugin toggle */
  91. $$if Control.Selected
  92. Rec_$Worksheet.name$.Value_$Control.name$ = 1;
  93. $$endif
  94. $$if Control.Unselected
  95. Rec_$Worksheet.name$.Value_$Control.name$ = 0;
  96. $$endif
  97. $$EndLoop
  98. $$Loop Control.type = UGauge
  99. Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;        /* Plugin gauge */
  100. Rec_$Worksheet.name$.Value_$Control.name$ = $Control.ValueScroll$;
  101. $$EndLoop
  102. $$Loop Control.type = Popup
  103. Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;        /* Popup menu */
  104. Rec_$Worksheet.name$.Value_$Control.name$ = $Control.SelectedID$;
  105. $$EndLoop
  106. $$Loop Control.type = Palette
  107. Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;        /* Palette */
  108. Rec_$Worksheet.name$.Value_$Control.name$ = $Control.ValueScroll$;
  109. $$EndLoop
  110. $$Loop Control.type = List
  111. Rec_$Worksheet.name$.List_$Control.name$ = nil;                        /* List */
  112. SetRect(&Rec_$Worksheet.name$.ListRect_$Control.name$,$Control.LeftPosition$,$Control.TopPosition$,$Control.RightPosition$,$Control.BottomPosition$);                /* left,top,right,bottom */
  113. $$EndLoop
  114. $$Loop Control.type = EditText
  115. Rec_$Worksheet.name$.TE_$Control.name$ = nil;                        /* Edit Text */
  116. SetRect(&Rec_$Worksheet.name$.TERect_$Control.name$,$Control.LeftPosition$,$Control.TopPosition$,$Control.RightPosition$,$Control.BottomPosition$);                /* left,top,right,bottom */
  117. GetIndString(Rec_$Worksheet.name$.TEStr_$Control.name$,sResD_$Control.name$,1);/*  ...Edit text, default value  */
  118. $$EndLoop
  119.  
  120. D_Init_$Worksheet.name$();
  121. }
  122.  
  123. /* ======================================================= */
  124.  
  125. /* Routine: MyFilter */
  126. /* Purpose: Filter routine for dialog events */
  127.  
  128. static pascal Boolean MyFilter (DialogPtr theDialog ,EventRecord *theEvent,short *itemHit)
  129. {
  130. Point            MyPt;                            /* Current list selection point */
  131. Rect            tempRect;                        /* Temporary rectangle */
  132. short            DType;                            /* Type of dialog item */
  133. Handle            DItem;                            /* Handle to the dialog item */
  134. ControlHandle    CItem;                            /* Control handle */
  135. short            chCode;                            /* Key entered */
  136. short            code;                            /* Used for FindControl */
  137. long            LTemp;                            /* Used for time delay */
  138. char            MyCmdKey;                        /* The command key */
  139. Boolean            CmdDown;                        /* Flag for command key used */
  140. Boolean            valMyFilter;                    /* Value to return */
  141.  
  142.  
  143. /* Call the user routine */
  144. valMyFilter = D_Filter_$Worksheet.name$(theDialog, theEvent, itemHit);
  145.  
  146. /* Only do on an update */
  147. if ((theEvent->what == updateEvt)  && ((WindowPtr)theEvent->message == theDialog))
  148.     {
  149.     BeginUpdate(theDialog);                        /* Start the update */
  150.     DrawDialog(theDialog);                        /* Draw the controls */
  151.     valMyFilter = TRUE;                            /* Pass out this special itemHit number */
  152.     *itemHit = 32000;                            /* Our special ID */
  153.     }
  154.  
  155. if (theEvent->what == mouseDown)                /* Only do on a mouse click */
  156.     {
  157.     MyPt = theEvent->where;                        /* Get the point where the mouse was clicked */
  158.     GlobalToLocal(&MyPt);                        /* Convert global to local */
  159.  
  160.     $$Loop Control.type = List
  161.     if (PtInRect(MyPt,&Rec_$Worksheet.name$.ListRect_$Control.name$))
  162.         ClickInTheList(MyPt,theEvent->modifiers,Rec_$Worksheet.name$.List_$Control.name$,$Control.TextSize$,$Control.TextFont$,$Control.TextStyle$,true);
  163.  
  164.     $$EndLoop
  165.     $$Loop Control.type = ScrollBar
  166.     GetDItem (theDialog ,ResD_$Control.name$, &DType, &DItem, &tempRect);/* Get the item */
  167.     if (PtInRect(MyPt,&tempRect))
  168.         {
  169.         CItem = (ControlHandle)DItem;            /* Make it a controlhandle */
  170.         code = TestControl(CItem,MyPt);            /* Get where in the Scrollbar we were pressed */
  171.         HandleWScrollBar(MyPt,code,$Control.StepScroll$,$Control.PageScroll$,CItem);/* Handle the scrollbar */
  172.         }
  173.  
  174.     $$EndLoop
  175.     $$Loop Control.type = UGauge
  176.     GetDItem (theDialog ,ResD_$Control.name$, &DType, &DItem, &tempRect);/* Get the item */
  177.     if (PtInRect(MyPt,&tempRect))
  178.         {
  179.         CItem = (ControlHandle)DItem;            /* Make it a controlhandle */
  180.         code = TestControl(CItem,MyPt);            /* Get where in the gauge we were pressed */
  181.         HandleWScrollBar(MyPt,code,$Control.StepScroll$,$Control.PageScroll$,CItem);/* Handle the scrollbar */
  182.         }
  183.  
  184.     $$EndLoop
  185.     }
  186.  
  187. CheckKeysInDialog(theDialog,&valMyFilter,theEvent,itemHit);
  188.  
  189. return(valMyFilter);
  190. }
  191.  
  192. /* ======================================================= */
  193.  
  194. /* Routine: Refresh_Dialog */
  195. /* Purpose: Refresh the dialogs non-controls */
  196.  
  197. static void Refresh_Dialog(void)
  198. {
  199. Rect            rTempRect;                        /* Temp rectangle used for drawing */
  200. short            DType;                            /* Type of dialog item */
  201. Handle            DItem;                            /* Handle to the dialog item */
  202. ControlHandle    CItem;                            /* Control handle */
  203. RGBColor        Saved_ForeColor;                /* Save colors */
  204. RGBColor        Saved_BackColor;                /* Save colors */
  205. RGBColor        DrawingColor;                    /* Place to make colors */
  206.  
  207.  
  208. SetPort(Rec_$Worksheet.name$.theDialog);        /* Point to our dialog window */
  209. rTempRect = tempRect;                            /* Save the current contents of  tempRect */
  210. if (Has.ColorQD)                                /* See if color QuickDraw is around */
  211.     {
  212.     GetForeColor(&Saved_ForeColor);                /* Save the fore color */
  213.     GetBackColor(&Saved_BackColor);                /* Save the back color */
  214.  
  215.     RGBForeColor(&Black_ForeColor);                /* Set the fore color to Black */
  216.     RGBBackColor(&White_BackColor);                /* Set the back color to White */
  217.     }
  218.  
  219. $$Loop Control.type = Button
  220. $$if Control.Default
  221. /* This is the default selection, when RETURN is pressed. */
  222. HiliteDefaultButton(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$);
  223.  
  224. $$endif Control.Default
  225. $$EndLoop Control.type
  226. $$Loop Control.type = Line
  227. /* Draw a line, $Control.FullName$ */
  228. $$if Control.GrayLine
  229. PenPat(&qd.gray);                                /* Set the gray pen pattern */
  230. $$endif Control.GrayLine
  231. $$if Control.LineWidth ! 1
  232. PenSize($Control.LineWidth$,$Control.LineWidth$);
  233. $$endif Control.LineWidth
  234. MoveTo($Control.LeftPosition$,$Control.TopPosition$);        /* Horz,vert, Move to starting position */
  235. LineTo($Control.RightPosition$,$Control.BottomPosition$);    /* Horz,vert, Draw to the ending position */
  236. $$if Control.LineWidth ! 1
  237. PenSize(1,1);
  238. $$endif Control.LineWidth
  239. $$if Control.GrayLine
  240. PenPat(&qd.black);                                /*  Back to default pen pattern  */
  241. $$endif Control.GrayLine
  242.  
  243. $$EndLoop
  244. $$Loop Control.type = StaticText
  245. $$if Control.SpecialText
  246. /* Draw static text */
  247. $$if Control.TextColor ! Black
  248. if (Has.ColorQD)                                    /* See if color QuickDraw is around */
  249.     {
  250.     DrawingColor.red = 0x$Control.RedTextColor$;
  251.     DrawingColor.green = 0x$Control.GreenTextColor$;
  252.     DrawingColor.blue = 0x$Control.BlueTextColor$;
  253.     RGBForeColor(&DrawingColor);                    /* Set the fore color */
  254.     RGBBackColor(&Saved_BackColor);                    /* Set the back color */
  255.     }
  256. $$endif Control.TextColor
  257. $$if Control.MultipleLine
  258. SetRect(&tempRect,$Control.LeftPosition$,$Control.TopPosition$,$Control.RightPosition$,$Control.BottomPosition$);
  259. DrawStaticTextBox(sResD_$Control.name$,&tempRect,$Control.TextAlignment$,$Control.TextSize$,$Control.TextFont$,$Control.TextStyle$);
  260. $$endif Control.MultipleLine
  261. $$if Control.SingleLine
  262. DrawStaticLine(sResD_$Control.name$,$Control.LeftPosition$,$Control.TopPosition$,$Control.TextSize$,$Control.TextFont$,$Control.TextStyle$);
  263. $$endif Control.SingleLine
  264. $$if Control.TextColor ! Black
  265. if (Has.ColorQD)                                    /* See if color QuickDraw is around */
  266.     {
  267.     RGBForeColor(&Black_ForeColor);                    /* Set the fore color */
  268.     RGBBackColor(&White_BackColor);                    /* Set the back color */
  269.     }
  270. $$endif Control.TextColor
  271.  
  272. $$endif Control.SpecialText
  273. $$EndLoop
  274. $$Loop Control.type = List
  275. UpdateTheList(Rec_$Worksheet.name$.theDialog->visRgn,Rec_$Worksheet.name$.List_$Control.name$,
  276.     &Rec_$Worksheet.name$.ListRect_$Control.name$,$Control.TextSize$,$Control.TextFont$,$Control.TextStyle$,true);
  277.  
  278. $$EndLoop
  279. TextSize(12);
  280. TextFont(systemFont);                                /* Select the Font that we want */
  281. TextFace(0);                                        /* Select the style that we want */
  282.  
  283. if (Has.ColorQD)                                /* See if color QuickDraw is around */
  284.     {
  285.     RGBForeColor(&Saved_ForeColor);                /* Restore the fore color */
  286.     RGBBackColor(&Saved_BackColor);                /* Restore the back color */
  287.     }
  288.  
  289. D_Refresh_$Worksheet.name$(Rec_$Worksheet.name$.theDialog);                /* Call user refresh routine */
  290. }
  291.  
  292. /* ======================================================= */
  293.  
  294. /* Routine: MPD_$Worksheet.name$ */
  295. /* Purpose: Modal dialog */
  296.  
  297. void MPD_$Worksheet.name$(void)
  298. {
  299. Rect        tempRect;                                /* Temporary rectangle */
  300. short        DType;                                    /* Type of dialog item */
  301. short        Index;                                    /* For looping */
  302. Handle        DItem;                                    /* Handle to the dialog item */
  303. ControlHandle    CItem;                                /* Control handle */
  304. ControlHandle    CTempItem;                            /* Control handle */
  305. Str255        sTemp;                                    /* Get text entered, temp holding */
  306. short        itemHit;                                /* Get selection */
  307. short        temp;                                    /* Get selection, temp holding */
  308. short        theSelection;                            /* For Palettes */
  309. long        theLong,LTemp2;                            /* For Hotspot setup */
  310. short        theRow;                                    /* This is used to define the row used in a list */
  311. FontInfo    ThisFontInfo;                            /* Used to determine List element height */
  312. TEHandle    ThisEditText;                            /* Handle to get the Dialogs TE record */
  313. GrafPtr        SavedPort;                                /* Previous grafport */
  314. Boolean        ExitDialog;                             /* Flag used to exit the Dialog */
  315. Point        MyPt;
  316. #if defined(powerc) || defined(__powerc)
  317. ModalFilterUPP    theFilter;
  318. #endif
  319.  
  320.  
  321. #if defined(powerc) || defined(__powerc)
  322. theFilter = NewModalFilterProc(MyFilter);
  323. #endif
  324. GetPort(&SavedPort);                                /* Get the previous grafport */
  325. HoldOffUserEvents = true;                            /* Hold off the user events */
  326.  
  327. Rec_$Worksheet.name$.theDialog = GetNewDialog(ResD_$Worksheet.name$,nil,(WindowPtr)-1);/* Bring in the dialog resource */
  328. SetPort(Rec_$Worksheet.name$.theDialog);            /* Prepare to add conditional text */
  329.  
  330. $$if Worksheet.Center
  331. tempRect = Rec_$Worksheet.name$.theDialog->portRect;            /* Get the windows position and size */
  332. $$if Worksheet.CenterHorz
  333. tempRect.left = ((screenRect.bounds.right - screenRect.bounds.left) - (tempRect.right - tempRect.left)) / 2;    /* Center Horz */
  334. $$endif Worksheet.CenterHorz
  335. $$if Worksheet.CenterVert
  336. tempRect.top = ((screenRect.bounds.bottom - screenRect.bounds.top) - (tempRect.bottom - tempRect.top)) / 3;    /* 1/3 vert */
  337.     if (tempRect.top < 40)                            /* Keep below the menu bar */
  338.     tempRect.top = 40;
  339. $$endif Worksheet.CenterVert
  340. MoveWindow(Rec_$Worksheet.name$.theDialog,tempRect.left,tempRect.top,true);
  341.  
  342. $$endif
  343. $$Loop Control.type = Button
  344. /* Button */
  345. SetupNormalControl(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,Rec_$Worksheet.name$.Enable_$Control.name$,0);
  346.  
  347. $$EndLoop Button
  348. $$Loop Control.type = Checkbox
  349. /* Checkbox */
  350. SetupNormalControl(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,Rec_$Worksheet.name$.Enable_$Control.name$,
  351.     Rec_$Worksheet.name$.Value_$Control.name$);
  352.  
  353. $$EndLoop Checkbox
  354. $$Loop Control.type = Radio
  355. /* Radio button */
  356. SetupNormalControl(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,Rec_$Worksheet.name$.Enable_$Control.name$,
  357.     Rec_$Worksheet.name$.Value_$Control.name$);
  358.  
  359. $$EndLoop Radio
  360. $$Loop Control.type = List
  361. /* Make a List */
  362. Make_A_List(&Rec_$Worksheet.name$.List_$Control.name$,&Rec_$Worksheet.name$.ListRect_$Control.name$,
  363.     Rec_$Worksheet.name$.theDialog,sResD_$Control.name$,$Control.TextSize$,$Control.TextFont$,$Control.TextStyle$,true);
  364.  
  365. $$EndLoop
  366. $$Loop Control.type = HotRect
  367. /* Draw a Hotspot or Rectangle */
  368. SetupHotSpot(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,$Control.MakeHotSpot$,$Control.LineWidth$,
  369.     $Control.ShadowWidth$,sResD_$Control.name$,Rec_$Worksheet.name$.Enable_$Control.name$);
  370.  
  371. $$EndLoop
  372. $$Loop Control.type = EditText
  373. GetDItem(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,&DType,&DItem,&tempRect);/* Get the item handle */
  374. GetIndString(sTemp,sResD_$Control.name$,1);            /* ...Edit text, default value */
  375. SetIText(DItem,sTemp);                                /* Set the default text string */
  376. SelIText(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,0,300);
  377.  
  378. $$EndLoop
  379. $$Loop Control.type = Popup
  380. SetupPopupMenu(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,Rec_$Worksheet.name$.Enable_$Control.name$,
  381.     mResD_$Control.name$,Rec_$Worksheet.name$.Value_$Control.name$);
  382.  
  383. $$EndLoop
  384. $$Loop Control.type = Picture
  385. $$if Control.NonGraphic
  386. /* Draw a picture */
  387. LTemp = ResD_N_$Control.name$;                        /* Picture ID and resize flag */
  388. $$if Control.ClipPicture
  389. LTemp = 0x00010000 | LTemp;
  390. $$endif Control.ClipPicture
  391. SetupTheItem(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,true,true,
  392.     Rec_$Worksheet.name$.Enable_$Control.name$,false,&tempRect,LTemp,0);/* Setup the Picture button */
  393.  
  394. $$endif Control.NonGraphic
  395. $$EndLoop
  396. $$Loop Control.type = Palette
  397. /* Draw a Palette */
  398. SetupPalette(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,Rec_$Worksheet.name$.Enable_$Control.name$,
  399.     $Control.NumRows$,$Control.NumColumns$,ResD_N_$Control.name$,$Control.HMethod$);
  400.  
  401. $$EndLoop
  402. $$Loop Control.type = Icon
  403. $$if Control.NonGraphic
  404. /* Draw an Icon button */
  405. SetupIconSicn(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,Rec_$Worksheet.name$.Enable_$Control.name$,
  406.     ResD_N_$Control.name$,ResD_H_$Control.name$);
  407.  
  408. $$endif Control.NonGraphic
  409. $$EndLoop
  410. $$Loop Control.type = Sicn
  411. /* Draw an Sicn */
  412. $$if Control.Graphic
  413. SetupIconSicn(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,Rec_$Worksheet.name$.Enable_$Control.name$,
  414.     ResD_N_$Control.name$,ResD_N_$Control.name$);
  415. $$endif Control.Graphic
  416. $$if Control.NonGraphic
  417. SetupIconSicn(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,Rec_$Worksheet.name$.Enable_$Control.name$,
  418.     ResD_N_$Control.name$,ResD_H_$Control.name$);
  419. $$endif Control.NonGraphic
  420.  
  421. $$EndLoop
  422. $$Loop Control.type = UButton
  423. SetupPlugin(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,Rec_$Worksheet.name$.Enable_$Control.name$,
  424.     ResD_N_$Control.name$,ResD_H_$Control.name$,sResD_$Control.name$);
  425.  
  426. $$EndLoop
  427. $$Loop Control.type = UToggle
  428. SetupPlugin(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,Rec_$Worksheet.name$.Enable_$Control.name$,
  429.     ResD_N_$Control.name$,ResD_H_$Control.name$,sResD_$Control.name$);
  430.  
  431. $$EndLoop
  432. $$Loop Control.type = UGauge
  433. SetupPlugin(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,Rec_$Worksheet.name$.Enable_$Control.name$,
  434.     ResD_N_$Control.name$,ResD_H_$Control.name$,sResD_$Control.name$);
  435. SetupMinMaxValue(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,$Control.MinScroll$,$Control.MaxScroll$,Rec_$Worksheet.name$.Value_$Control.name$);
  436.  
  437. $$EndLoop
  438. $$Loop Control.type = ScrollBar
  439. SetupTheItem(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,true,true,
  440.     Rec_$Worksheet.name$.Enable_$Control.name$,true,&tempRect,0,0);
  441. SetupMinMaxValue(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,$Control.MinScroll$,$Control.MaxScroll$,Rec_$Worksheet.name$.Value_$Control.name$);
  442.  
  443. $$EndLoop
  444.  
  445. ExitDialog = false;                                    /* Do not exit dialog handle loop yet */
  446.  
  447. $$Link    Worksheet.Open
  448.  
  449. D_Setup_$Worksheet.name$(Rec_$Worksheet.name$.theDialog);                /* Call user Dialog setup routine */
  450.  
  451. ShowWindow(Rec_$Worksheet.name$.theDialog);                            /* Open a dialog box */
  452. SelectWindow(Rec_$Worksheet.name$.theDialog);                            /* Lets see it */
  453.  
  454. do                                                    /* Start of dialog handle loop */
  455.     {
  456. #if defined(powerc) || defined(__powerc)
  457.     ModalDialog(theFilter,&itemHit);    /* Wait until an item is hit */
  458. #else
  459.     ModalDialog((ModalFilterProcPtr)&MyFilter,&itemHit);    /* Wait until an item is hit */
  460. #endif
  461.  
  462.     D_Hit_$Worksheet.name$(Rec_$Worksheet.name$.theDialog,&itemHit,&ExitDialog);/* Let user handle the item hit */
  463.  
  464.     if (itemHit == 32000)                            /* Check for update */
  465.         {
  466.         Refresh_Dialog();                            /* Draw any Lists, lines, or rectangles */
  467.         EndUpdate(Rec_$Worksheet.name$.theDialog);                     /* End of the update */
  468.         }
  469.     else
  470.         {
  471.         GetDItem(Rec_$Worksheet.name$.theDialog, itemHit, &DType, &DItem, &tempRect);/* Get item information */
  472.         CItem = (ControlHandle)DItem;                /* Get the control handle */
  473.         }
  474.  
  475.     /* Handle it real time */
  476.     $$Loop Control.type = Button
  477.     if (itemHit == ResD_$Control.name$)                /* Handle the Button being pressed */
  478.         {
  479.         $$Link    Control.Select
  480.         $$if Control.ExitDialog
  481.         ExitDialog = true;                            /* Close this dialog, exit */
  482.         $$endif Control.ExitDialog
  483.         }
  484.  
  485.     $$EndLoop Control.type
  486.     $$Loop Control.type = Checkbox
  487.     if (itemHit == ResD_$Control.name$)                /* Handle the checkbox being pressed */
  488.         {
  489.         temp = GetCtlValue(CItem);                    /* Get the current Checkbox value */
  490.         SetCtlValue(CItem, (temp + 1) & 1);            /* Toggle the value to the opposite */
  491.         Rec_$Worksheet.name$.Value_$Control.name$ = GetCtlValue(CItem);    /* Get the current Checkbox value */
  492.         $$if Control.HasLinks
  493.         if (Rec_$Worksheet.name$.Value_$Control.name$ == 0)
  494.             {
  495.             $$Link    Control.Deselect
  496.             }
  497.         else
  498.             {
  499.             $$Link    Control.Select
  500.             }
  501.         $$endif
  502.         }
  503.  
  504.     $$EndLoop Control.type
  505.     $$Loop Control.type = UButton
  506.     $$if Control.HasLinks
  507.     if (itemHit == ResD_$Control.name$)                /* Handle the Button being pressed */
  508.         {
  509.         $$Link    Control.Select
  510.         }
  511.  
  512.     $$endif
  513.     $$EndLoop Control.type
  514.     $$Loop Control.type = UToggle
  515.     if (itemHit == ResD_$Control.name$)                /* Handle the checkbox being pressed */
  516.         {
  517.         temp = GetCtlValue(CItem);                    /* Get the current Checkbox value */
  518.         SetCtlValue(CItem, (temp + 1) & 1);            /* Toggle the value to the opposite */
  519.         Rec_$Worksheet.name$.Value_$Control.name$ = GetCtlValue(CItem);    /* Get the current Checkbox value */
  520.         $$if Control.HasLinks
  521.         if (Rec_$Worksheet.name$.Value_$Control.name$ == 0)
  522.             {
  523.             $$Link    Control.Deselect
  524.             }
  525.         else
  526.             {
  527.             $$Link    Control.Select
  528.             }
  529.         $$endif
  530.         }
  531.  
  532.     $$EndLoop Control.type
  533.     $$Loop Control.type = Radio
  534.     if (itemHit == ResD_$Control.name$)            /* Handle the Radio being pressed */
  535.         {
  536.         SetCtlValue(CItem,1);
  537.         Rec_$Worksheet.name$.Value_$Control.name$ = 1;    /* Set the current Radio value */
  538.  
  539.         $$Loop RadioGroup
  540.         ClearTheRadio(Rec_$Worksheet.name$.theDialog,ResD_$Control.name$,&Rec_$Worksheet.name$.Value_$Control.name$);
  541.         $$EndLoop RadioGroup
  542.         $$Link    Control.Select
  543.         }
  544.  
  545.     $$EndLoop Control.type
  546.     $$Loop Control.type = HotRect
  547.     $$if Control.HotSpot
  548.     $$if Control.HasLinks
  549.     if (itemHit == ResD_$Control.name$)                /* Handle the HotSpot being pressed */
  550.         {
  551.         $$Link    Control.Select
  552.         }
  553.  
  554.     $$endif
  555.     $$endif Control.HotSpot
  556.     $$EndLoop
  557.     $$Loop Control.type = Popup
  558.     $$EndLoop
  559.     $$Loop Control.type = Picture
  560.     $$if Control.NonGraphic
  561.     $$if Control.HasLinks
  562.     if (itemHit == ResD_$Control.name$)                /* Handle the Picture being pressed */
  563.         {
  564.         $$Link    Control.Select
  565.         }
  566.  
  567.     $$endif
  568.     $$endif Control.NonGraphic
  569.     $$EndLoop
  570.     $$Loop Control.type = Palette
  571.     $$EndLoop
  572.     $$Loop Control.type = Icon
  573.     $$if Control.NonGraphic
  574.     $$if Control.HasLinks
  575.     if (itemHit == ResD_$Control.name$)                /* Handle the Icon being pressed */
  576.         {
  577.         $$Link    Control.Select
  578.         }
  579.  
  580.     $$endif
  581.     $$endif Control.NonGraphic
  582.     $$EndLoop
  583.     $$Loop Control.type = Sicn
  584.     $$if Control.NonGraphic
  585.     $$if Control.HasLinks
  586.     if (itemHit == ResD_$Control.name$)                /* Handle the Sicn being pressed */
  587.         {
  588.         $$Link    Control.Select
  589.         }
  590.  
  591.     $$endif
  592.     $$endif Control.NonGraphic
  593.     $$EndLoop
  594.  
  595.     }
  596. while (!ExitDialog);                                /* Handle dialog items until exit selected */
  597.  
  598. /* Get results after dialog */
  599.  
  600. D_Exit_$Worksheet.name$(Rec_$Worksheet.name$.theDialog);    /* Exiting the modal dialog */
  601.  
  602. $$Link    Worksheet.Close
  603.  
  604. SetPort(SavedPort);                                    /* Restore the previous grafport */
  605. DisposDialog(Rec_$Worksheet.name$.theDialog);        /* Flush the dialog out of memory */
  606.  
  607. HoldOffUserEvents = false;                            /* Let in the user events */
  608. }
  609.  
  610. /* ======================================================= */
  611. /* ======================================================= */
  612. $$CloseFile
  613. $$EndLoop
  614.  
  615.  
  616.